// pages/help/writeRemark/writeRemark.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    helpId:0,
    userId:wx.getStorageSync('userId'),
    createBy:wx.getStorageSync('username'),
    status:0,
    content:"",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      helpId:options.id
    })
  },
  //检测富文本编辑器输入内容
  onInputtingDesc: function (e) {
    let html = e.detail.html;   //相关的html代码
    this.setData({
      content: html,
    });
  },
  //提交评论内容
  onTapButton:function(){
    if(this.data.content==""){
      wx.showToast({title: '请输入评论内容',icon: 'none',duration: 1000})
    }else{
      app.$http.post('/app/remark/add',this.data).then(resp=>{
        wx.reLaunch({
          url: '/pages/index/help/help?id='+this.data.helpId,
        })()
      }).catch(err=>{
        console.log(err)
      })
    }
  }
})